import request from '../../utils/request2';


import urls from '../../utils/urls';

interface LoginParams {
  username: string;
  password: string;
}

let processName = urls.online;
let processVerification = urls.verification;

enum Api {
  Login = '/login',
  Logout = '/logout',
  GetUserInfo = '',
  GetPermCode = 'other/jwt/getJWT',
}

/**
 * @description: user login api
 */
export function loginApi(params: LoginParams) {
  return request({
    url:  processName + Api.Login,
    params:params,
    method: 'get',
  })
}



/**
 * @description: getUserInfo
 */
export function getUserInfo(params:object) {
  return request({
    url:  Api.GetUserInfo,
    params:params,
    method: 'get',
  })
}

/**
 * @description: getUserInfo
 */
 export function GetPermCode(params:object) {
  return request({
    url:  processName + Api.GetPermCode,
    params:params,
    method: 'get',
  })
}

export function GetTokenFn(code) {
  return request({
    url:   `http://10.81.106.123/idp/oauth2/getToken?client_id=hwyxgl&grant_type=authorization_code&code=${code}&client_secret=77a48b79b41a46c7b80ee4fa377d6dc9`,
    method: 'post',
  })
}

export function GetNewInfo(params) {
  return request({
    url:   `http://10.81.106.123/idp/oauth2/getUserInfo?access_token=${params.access_token}&client_id=hwyxgl&uid=${params.uid}`,
    method: 'get',
  })
}

// 获取token

export function GetCode() {
  return request({
    url:   'http://10.81.106.123/idp/oauth2/authorize?redirect_uri=http://10.81.106.123&state=123&client_id=hwyxgl&response_type=code',
    method: 'get',
  })
}




export function doLogout() {
  return request({
    url:  processName + Api.Logout,
    method: 'get',
  })
}

